package d1123;

import java.util.ArrayList;
import java.util.List;

//list 集合的索引
public class Demo02List02 {
    public static void main(String[] args) {
        List list =new ArrayList();//多态
        list.add("贾宝玉");
        list.add("林黛玉");
        list.add("薛宝钗");
        list.add("王熙凤");
        list.add("贾宝玉");
        //数组                0 arr.length-1
        //索引  和数组一样的思路 0 list.size()-1


        System.out.println(list);
        list.add(0,"名烟");
        System.out.println(list);
        //删除指定位置的元素
        System.out.println(list.remove(3));
        System.out.println(list);
        //list 修改
        list.set(3,"平儿");
        System.out.println(list);
        //查询
        System.out.println(list.get(1));



    }
}
